@@ -60,6 +60,7 @@ group :test do |
||
60 | 60 |
gem "webrat" |
61 | 61 |
gem 'cucumber-rails', :require => false |
62 | 62 |
gem 'database_cleaner' |
63 |
+ gem "factory_girl_rails", "~> 4.0", :require => false |
|
63 | 64 |
end |
64 | 65 |
|
65 | 66 |
# Use ActiveModel has_secure_password |
@@ -75,6 +75,11 @@ GEM |
||
75 | 75 |
erubis (2.7.0) |
76 | 76 |
excon (0.39.5) |
77 | 77 |
execjs (2.2.1) |
78 |
+ factory_girl (4.5.0) |
|
79 |
+ activesupport (>= 3.0.0) |
|
80 |
+ factory_girl_rails (4.5.0) |
|
81 |
+ factory_girl (~> 4.5.0) |
|
82 |
+ railties (>= 3.0.0) |
|
78 | 83 |
figaro (1.0.0) |
79 | 84 |
thor (~> 0.14) |
80 | 85 |
flatstrap-rails (0.3.0.2) |
@@ -262,6 +267,7 @@ DEPENDENCIES |
||
262 | 267 |
cucumber-rails |
263 | 268 |
database_cleaner |
264 | 269 |
devise |
270 |
+ factory_girl_rails (~> 4.0) |
|
265 | 271 |
figaro |
266 | 272 |
flatstrap-rails |
267 | 273 |
fog |
@@ -0,0 +1,24 @@ |
||
1 |
+Feature: Manage Articles |
|
2 |
+ In order to make a blog |
|
3 |
+ As an author |
|
4 |
+ I want to create and manage blog psots |
|
5 |
+ |
|
6 |
+ Background: |
|
7 |
+ Given the following blog_post list |
|
8 |
+ | title | content | published | description | slug | |
|
9 |
+ | Hello World | Welcome to the website | true | First Post | hello_world | |
|
10 |
+ | Test 001 | 1 2 3 testing | true | Testing the website | test_001 | |
|
11 |
+ |
|
12 |
+ @focus |
|
13 |
+ Scenario: Blog Posts List |
|
14 |
+ When I go to the blog page |
|
15 |
+ Then I should see "Hello World" |
|
16 |
+ And I should see "First Post" |
|
17 |
+ And I should see "Test 001" |
|
18 |
+ And I should see "Testing the website" |
|
19 |
+ |
|
20 |
+ Scenario: Posts Page |
|
21 |
+ When I go to the blog page |
|
22 |
+ And I click in the link "Hello World" |
|
23 |
+ Then I should see "Hello World" |
|
24 |
+ And I should see "Welcome to the website" |
@@ -1,9 +0,0 @@ |
||
1 |
-Feature: Manage Articles |
|
2 |
- In order to make a blog |
|
3 |
- As an author |
|
4 |
- I want to create and manage articles |
|
5 |
- |
|
6 |
-Scenario: Blog Posts List |
|
7 |
- Given I have blog posts titled Pizza, Breadsticks |
|
8 |
- When I go to the blog page |
|
9 |
- Then I should see "Pizza" And I should see "Breadsticks" |
@@ -1,16 +1,30 @@ |
||
1 | 1 |
Info.create( :website_name => 'Website', :tagline => 'A Ruby on Rails app template', :default_language => 'en' ) |
2 | 2 |
|
3 |
+Given /^the following (.+) list ?$/ do |factory, table| |
|
4 |
+ table.hashes.each do |hash| |
|
5 |
+ FactoryGirl.create(factory, hash) |
|
6 |
+ end |
|
7 |
+end |
|
8 |
+ |
|
3 | 9 |
Given /^I have blog posts titled (.+)$/ do |titles| |
4 | 10 |
titles.split(', ').each do |title| |
5 | 11 |
BlogPost.create!(:title => title) |
6 | 12 |
end |
7 | 13 |
end |
8 | 14 |
|
9 |
-When(/^I go to the blog page$/) do |
|
10 |
- visit blog_path |
|
15 |
+When /^I go to (.+)$/ do |page_name| |
|
16 |
+ path_to(page_name) |
|
17 |
+end |
|
18 |
+ |
|
19 |
+Then(/^I should see "(.*?)"$/) do |arg1| |
|
20 |
+ page.should have_content(arg1) |
|
11 | 21 |
end |
12 | 22 |
|
13 | 23 |
Then(/^I should see "(.*?)" And I should see "(.*?)"$/) do |arg1, arg2| |
14 | 24 |
page.should have_content(arg1) |
15 | 25 |
page.should have_content(arg2) |
16 |
-end |
|
26 |
+end |
|
27 |
+ |
|
28 |
+When(/^I click in the link "(.*?)"$/) do |arg1| |
|
29 |
+ click_link arg1 |
|
30 |
+end |
@@ -55,4 +55,6 @@ end |
||
55 | 55 |
# The :transaction strategy is faster, but might give you threading problems. |
56 | 56 |
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature |
57 | 57 |
Cucumber::Rails::Database.javascript_strategy = :truncation |
58 |
+require "#{Rails.root}/spec/factories.rb" |
|
59 |
+ |
|
58 | 60 |
|
@@ -0,0 +1,20 @@ |
||
1 |
+module NavigationHelpers |
|
2 |
+ |
|
3 |
+ def path_to(page_name) |
|
4 |
+ |
|
5 |
+ case page_name |
|
6 |
+ |
|
7 |
+ when/the homepage/ |
|
8 |
+ root_path |
|
9 |
+ |
|
10 |
+ when/the blog page/ |
|
11 |
+ visit blog_path |
|
12 |
+ |
|
13 |
+ else |
|
14 |
+ raise "Can't find mapping from \"#{page_name}\" to a path." |
|
15 |
+ end |
|
16 |
+ |
|
17 |
+ end |
|
18 |
+end |
|
19 |
+ |
|
20 |
+World(NavigationHelpers) |
@@ -52,6 +52,7 @@ A template for creating rails websites that includes the following: |
||
52 | 52 |
* Store |
53 | 53 |
* Inventory |
54 | 54 |
* Module Controller |
55 |
+* Newsletter signup |
|
55 | 56 |
|
56 | 57 |
## BUGS |
57 | 58 |
|
@@ -0,0 +1,22 @@ |
||
1 |
+require 'factory_girl' |
|
2 |
+ |
|
3 |
+FactoryGirl.define do |
|
4 |
+ |
|
5 |
+ factory :user, aliases: [:author, :owner] do |
|
6 |
+ first_name "John" |
|
7 |
+ last_name "Doe" |
|
8 |
+ email "johndoe@website.com" |
|
9 |
+ password "12345678" |
|
10 |
+ end |
|
11 |
+ |
|
12 |
+ factory :blog_post do |f| |
|
13 |
+ f.title "foo" |
|
14 |
+ f.slug "foo" |
|
15 |
+ f.content "foobar" |
|
16 |
+ f.published true |
|
17 |
+ f.description "foobar is cool" |
|
18 |
+ association :author, factory: :user, last_name: "Doe", strategy: :build |
|
19 |
+ end |
|
20 |
+ |
|
21 |
+end |
|
22 |
+ |
@@ -0,0 +1,50 @@ |
||
1 |
+# This file is copied to spec/ when you run 'rails generate rspec:install' |
|
2 |
+ENV["RAILS_ENV"] ||= 'test' |
|
3 |
+require 'spec_helper' |
|
4 |
+require File.expand_path("../../config/environment", __FILE__) |
|
5 |
+require 'rspec/rails' |
|
6 |
+# Add additional requires below this line. Rails is not loaded until this point! |
|
7 |
+ |
|
8 |
+# Requires supporting ruby files with custom matchers and macros, etc, in |
|
9 |
+# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are |
|
10 |
+# run as spec files by default. This means that files in spec/support that end |
|
11 |
+# in _spec.rb will both be required and run as specs, causing the specs to be |
|
12 |
+# run twice. It is recommended that you do not name files matching this glob to |
|
13 |
+# end with _spec.rb. You can configure this pattern with the --pattern |
|
14 |
+# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. |
|
15 |
+# |
|
16 |
+# The following line is provided for convenience purposes. It has the downside |
|
17 |
+# of increasing the boot-up time by auto-requiring all files in the support |
|
18 |
+# directory. Alternatively, in the individual `*_spec.rb` files, manually |
|
19 |
+# require only the support files necessary. |
|
20 |
+# |
|
21 |
+# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } |
|
22 |
+ |
|
23 |
+# Checks for pending migrations before tests are run. |
|
24 |
+# If you are not using ActiveRecord, you can remove this line. |
|
25 |
+ActiveRecord::Migration.check_pending! |
|
26 |
+ |
|
27 |
+RSpec.configure do |config| |
|
28 |
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures |
|
29 |
+ config.fixture_path = "#{::Rails.root}/spec/fixtures" |
|
30 |
+ |
|
31 |
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your |
|
32 |
+ # examples within a transaction, remove the following line or assign false |
|
33 |
+ # instead of true. |
|
34 |
+ config.use_transactional_fixtures = true |
|
35 |
+ |
|
36 |
+ # RSpec Rails can automatically mix in different behaviours to your tests |
|
37 |
+ # based on their file location, for example enabling you to call `get` and |
|
38 |
+ # `post` in specs under `spec/controllers`. |
|
39 |
+ # |
|
40 |
+ # You can disable this behaviour by removing the line below, and instead |
|
41 |
+ # explicitly tag your specs with their type, e.g.: |
|
42 |
+ # |
|
43 |
+ # RSpec.describe UsersController, :type => :controller do |
|
44 |
+ # # ... |
|
45 |
+ # end |
|
46 |
+ # |
|
47 |
+ # The different available types are documented in the features, such as in |
|
48 |
+ # https://relishapp.com/rspec/rspec-rails/docs |
|
49 |
+ config.infer_spec_type_from_file_location! |
|
50 |
+end |
@@ -0,0 +1,90 @@ |
||
1 |
+# This file was generated by the `rails generate rspec:install` command. Conventionally, all |
|
2 |
+# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. |
|
3 |
+# The generated `.rspec` file contains `--require spec_helper` which will cause this |
|
4 |
+# file to always be loaded, without a need to explicitly require it in any files. |
|
5 |
+# |
|
6 |
+# Given that it is always loaded, you are encouraged to keep this file as |
|
7 |
+# light-weight as possible. Requiring heavyweight dependencies from this file |
|
8 |
+# will add to the boot time of your test suite on EVERY test run, even for an |
|
9 |
+# individual file that may not need all of that loaded. Instead, consider making |
|
10 |
+# a separate helper file that requires the additional dependencies and performs |
|
11 |
+# the additional setup, and require it from the spec files that actually need it. |
|
12 |
+# |
|
13 |
+# The `.rspec` file also contains a few flags that are not defaults but that |
|
14 |
+# users commonly want. |
|
15 |
+# |
|
16 |
+# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration |
|
17 |
+ |
|
18 |
+ |
|
19 |
+ |
|
20 |
+ |
|
21 |
+RSpec.configure do |config| |
|
22 |
+ |
|
23 |
+ # rspec-expectations config goes here. You can use an alternate |
|
24 |
+ # assertion/expectation library such as wrong or the stdlib/minitest |
|
25 |
+ # assertions if you prefer. |
|
26 |
+ config.expect_with :rspec do |expectations| |
|
27 |
+ # This option will default to `true` in RSpec 4. It makes the `description` |
|
28 |
+ # and `failure_message` of custom matchers include text for helper methods |
|
29 |
+ # defined using `chain`, e.g.: |
|
30 |
+ # be_bigger_than(2).and_smaller_than(4).description |
|
31 |
+ # # => "be bigger than 2 and smaller than 4" |
|
32 |
+ # ...rather than: |
|
33 |
+ # # => "be bigger than 2" |
|
34 |
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true |
|
35 |
+ end |
|
36 |
+ |
|
37 |
+ # rspec-mocks config goes here. You can use an alternate test double |
|
38 |
+ # library (such as bogus or mocha) by changing the `mock_with` option here. |
|
39 |
+ config.mock_with :rspec do |mocks| |
|
40 |
+ # Prevents you from mocking or stubbing a method that does not exist on |
|
41 |
+ # a real object. This is generally recommended, and will default to |
|
42 |
+ # `true` in RSpec 4. |
|
43 |
+ mocks.verify_partial_doubles = true |
|
44 |
+ end |
|
45 |
+ |
|
46 |
+# The settings below are suggested to provide a good initial experience |
|
47 |
+# with RSpec, but feel free to customize to your heart's content. |
|
48 |
+=begin |
|
49 |
+ # These two settings work together to allow you to limit a spec run |
|
50 |
+ # to individual examples or groups you care about by tagging them with |
|
51 |
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples |
|
52 |
+ # get run. |
|
53 |
+ config.filter_run :focus |
|
54 |
+ config.run_all_when_everything_filtered = true |
|
55 |
+ |
|
56 |
+ # Limits the available syntax to the non-monkey patched syntax that is recommended. |
|
57 |
+ # For more details, see: |
|
58 |
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax |
|
59 |
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ |
|
60 |
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching |
|
61 |
+ config.disable_monkey_patching! |
|
62 |
+ |
|
63 |
+ # Many RSpec users commonly either run the entire suite or an individual |
|
64 |
+ # file, and it's useful to allow more verbose output when running an |
|
65 |
+ # individual spec file. |
|
66 |
+ if config.files_to_run.one? |
|
67 |
+ # Use the documentation formatter for detailed output, |
|
68 |
+ # unless a formatter has already been configured |
|
69 |
+ # (e.g. via a command-line flag). |
|
70 |
+ config.default_formatter = 'doc' |
|
71 |
+ end |
|
72 |
+ |
|
73 |
+ # Print the 10 slowest examples and example groups at the |
|
74 |
+ # end of the spec run, to help surface which specs are running |
|
75 |
+ # particularly slow. |
|
76 |
+ config.profile_examples = 10 |
|
77 |
+ |
|
78 |
+ # Run specs in random order to surface order dependencies. If you find an |
|
79 |
+ # order dependency and want to debug it, you can fix the order by providing |
|
80 |
+ # the seed, which is printed after each run. |
|
81 |
+ # --seed 1234 |
|
82 |
+ config.order = :random |
|
83 |
+ |
|
84 |
+ # Seed global randomization in this process using the `--seed` CLI option. |
|
85 |
+ # Setting this allows you to use `--seed` to deterministically reproduce |
|
86 |
+ # test failures related to randomization by passing the same `--seed` value |
|
87 |
+ # as the one that triggered the failure. |
|
88 |
+ Kernel.srand config.seed |
|
89 |
+=end |
|
90 |
+end |